package com.ruoyi.life.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.omp.api.domain.FeParking;
import com.ruoyi.life.service.IFeParkingService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 车位费用Controller
 *
 * @author cjie
 * @date 2021-09-17
 */
@Api(tags = " 车位费用")
@RestController
@RequestMapping("/feParking")
public class FeParkingController extends BaseController {
    @Autowired
    private IFeParkingService feParkingService;

    /**
     * 查询车位费用列表
     */
    @ApiOperation(value="查询车位费用列表", notes="查询车位费用列表")
    @PreAuthorize(hasPermi = "life:feParking:list")
    @GetMapping("/list")
    public TableDataInfo list(FeParking feParking) {
        startPage();
        List<FeParking> list = feParkingService.selectFeParkingList(feParking);
        return getDataTable(list);
    }

    /**
     * 导出车位费用列表
     */
    @ApiOperation(value="导出车位费用列表", notes="导出车位费用列表")
    @PreAuthorize(hasPermi = "life:feParking:export")
    @Log(title = "车位费用", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeParking feParking) throws IOException {
        List<FeParking> list = feParkingService.selectFeParkingList(feParking);
        ExcelUtil<FeParking> util = new ExcelUtil<FeParking>(FeParking.class);
        util.exportExcel(response, list, "车位费用数据");
    }
    /**
     * 获取车位费用详细信息
     */
    @ApiOperation(value="获取车位费用详细信息", notes="获取车位费用详细信息")
    @PreAuthorize(hasPermi = "life:feParking:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(feParkingService.selectFeParkingById(id));
    }

    /**
     * 新增车位费用
     */
    @ApiOperation(value="新增车位费用", notes="新增车位费用")
    @PreAuthorize(hasPermi = "life:feParking:add")
    @Log(title = "车位费用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeParking feParking) {
        return toAjax(feParkingService.insertFeParking(feParking));
    }

    /**
     * 修改车位费用
     */
    @ApiOperation(value="修改车位费用", notes="修改车位费用")
    @PreAuthorize(hasPermi = "life:feParking:edit")
    @Log(title = "车位费用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeParking feParking) {
        return toAjax(feParkingService.updateFeParking(feParking));
    }

    /**
     * 删除车位费用
     */
    @ApiOperation(value="删除车位费用", notes="删除车位费用")
    @ApiImplicitParam(name = "ids", value = "车位费用ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "life:feParking:remove")
    @Log(title = "车位费用", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(feParkingService.deleteFeParkingByIds(ids));
    }
}
